package com.chixing.controller;


import com.chixing.service.BranchService;
import com.chixing.util.ServerResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class BranchController {
    @Autowired
    private BranchService branchService;

    @GetMapping("shoplist")
    public ModelAndView getAllShop() {

        ServerResult serverResult = branchService.getAllShop();
        ModelAndView mav = new ModelAndView();
        System.out.println("运行后的数据" + serverResult.getCode());
        if (serverResult.getCode() == 200) {
            System.out.println("======serverResult.getData()======" + serverResult.getData());
            mav.addObject("branchShop", serverResult.getData());
        } else {
            mav.addObject("branchShop", serverResult.getData());
        }
        mav.setViewName("car_rental/branch");
        System.out.println("返回页面");
        return mav;
    }


}
